#include <cstdio>
// TODO: 赛道修建
const int N = 100;
int n, m;
int e_cnt, heads[N];
struct Edge {
	int v, nxt, w;
} e[N << 1];
inline void add(int u, int v, int l) {
	e[++e_cnt].v = v, e[e_cnt].w = l, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("P1967.in", "r", stdin);
	freopen("P1967.out", "w", stdout);
#endif
#endif

	scanf("%d%d", &n, &m);
	int a, b, l;
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d%d", &a, &b, &l);
		add(a, b, l);
		add(b, a, l);
	}
	return 0;
}